package fun.coding.leetcode;

public class MajorityElement {

	public static void main(String[] args) {

	}
	
	public int majorityElement(int[] num) {
		int vote = 0;
		int res = 0;
		
		for (int i = 0; i < num.length; i++) {
			if (vote == 0) {
				res = num[i];
				vote++;
			} else {
				if (num[i] == res) {
					vote++;
				} else {
					vote--;
				}
			}
		}
		
		return res;
	}

}
